package com.test.nnooolwdeaer.dialog_wooden;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.test.nnooolwdeaer.R;
import com.test.nnooolwdeaer.bean_wooden.process_wooden.ProcessInfo_wooden;
import com.test.nnooolwdeaer.util_wooden.http_wooden.HttpManager_wooden;


public class CopyOrderNumberDialog_wooden extends Dialog {

    private TextView orderNumTv;
    private Button signNotCompleteBtn,signCompleteBtn;
    private ImageButton closeIb;

    private static final String pageTag="COPY_ORDER_NUMBER_DIALOG";

    public CopyOrderNumberDialog_wooden(@NonNull Context context) {
        super(context,R.style.BottomSheetDialogStyle);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_copy_order_number_wooden);

        getWindow().setBackgroundDrawableResource(R.color.trans);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        setCancelable(false);

        orderNumTv = findViewById(R.id.dl_copyordernum_tv_order_number);
        signNotCompleteBtn = findViewById(R.id.dl_copyordernum_btn_sign_not_complete);
        signCompleteBtn = findViewById(R.id.dl_copyordernum_btn_signed_complete);
        closeIb = findViewById(R.id.dl_copyordernum_ib_close);

        init_wooden();
    }

    @SuppressLint("SetTextI18n")
    private void init_wooden(){

        String orderId = ProcessInfo_wooden.getInstance_wooden().getSignOrderId();

        closeIb.setOnClickListener(v -> dismiss());

        orderNumTv.setText(orderId);

        signNotCompleteBtn.setOnClickListener(v -> {
            HttpManager_wooden.getInstance_wooden().saveUserBuriedPoint(pageTag+"_SIGN_NOT_COMPLETED_CLICK");
            dismiss();
        });

        signCompleteBtn.setOnClickListener(v -> {
            HttpManager_wooden.getInstance_wooden().saveUserBuriedPoint(pageTag+"_I_HAVE_SIGNED_CLICK");
            dismiss();
            HttpManager_wooden.getInstance_wooden().requestUserProcess_wooden();
        });

    }

    @Override
    public void show() {
        super.show();
        HttpManager_wooden.getInstance_wooden().saveUserBuriedPoint(pageTag+"_START");
    }

    @Override
    public void dismiss() {
        super.dismiss();
        HttpManager_wooden.getInstance_wooden().saveUserBuriedPoint(pageTag+"_END");
    }
}
